<template>
  <div class="modular-nav-system">
    <!-- 顶部模块导航 -->
    <div class="module-nav-bar">
      <div class="nav-brand">
        <el-icon><Grid /></el-icon>
        <span>ERP系统</span>
      </div>
      
      <div class="module-tabs">
        <div
          v-for="module in modules"
          :key="module.id"
          class="module-tab"
          :class="{ 'active': activeModule === module.id }"
          @click="selectModule(module)"
        >
          <div class="tab-icon">
            <el-icon><component :is="module.icon" /></el-icon>
          </div>
          <div class="tab-content">
            <div class="tab-title">{{ module.name }}</div>
            <div class="tab-desc">{{ module.description }}</div>
          </div>
          <div class="tab-badge" v-if="module.badge">
            <el-tag size="small" :type="module.badgeType">{{ module.badge }}</el-tag>
          </div>
        </div>
      </div>

      <div class="nav-actions">
        <el-button text @click="toggleGlobalSearch">
          <el-icon><Search /></el-icon>
        </el-button>
        <el-button text @click="toggleNotifications">
          <el-icon><Bell /></el-icon>
          <el-badge :value="5" class="notification-badge" />
        </el-button>
        <el-button text @click="toggleUserMenu">
          <el-icon><User /></el-icon>
        </el-button>
      </div>
    </div>

    <!-- 主内容区域 -->
    <div class="main-content">
      <!-- 左侧功能面板 -->
      <div class="function-sidebar" :class="{ 'collapsed': isSidebarCollapsed }">
        <div class="sidebar-header">
          <h3>{{ activeModuleName }}</h3>
          <el-button text @click="toggleSidebar">
            <el-icon><component :is="isSidebarCollapsed ? 'Expand' : 'Fold'" /></el-icon>
          </el-button>
        </div>

        <div class="sidebar-content">
          <!-- 功能分类 -->
          <div
            v-for="category in functionCategories"
            :key="category.id"
            class="function-category"
          >
            <div class="category-header" @click="toggleCategory(category.id)">
              <el-icon><component :is="category.icon" /></el-icon>
              <span>{{ category.name }}</span>
              <el-icon class="expand-icon">
                <component :is="category.expanded ? 'ArrowDown' : 'ArrowRight'" />
              </el-icon>
            </div>
            
            <transition name="category-slide">
              <div v-if="category.expanded" class="category-functions">
                <div
                  v-for="func in category.functions"
                  :key="func.id"
                  class="function-item"
                  :class="{ 'active': activeFunction === func.id }"
                  @click="selectFunction(func)"
                >
                  <el-icon><component :is="func.icon" /></el-icon>
                  <span>{{ func.name }}</span>
                  <el-badge v-if="func.count" :value="func.count" class="function-badge" />
                </div>
              </div>
            </transition>
          </div>
        </div>
      </div>

      <!-- 中间工作区域 -->
      <div class="work-area">
        <!-- 工作区头部 -->
        <div class="work-header">
          <div class="work-breadcrumb">
            <el-breadcrumb separator="/">
              <el-breadcrumb-item v-for="crumb in workBreadcrumbs" :key="crumb.path">
                <el-icon v-if="crumb.icon"><component :is="crumb.icon" /></el-icon>
                {{ crumb.name }}
              </el-breadcrumb-item>
            </el-breadcrumb>
          </div>
          
          <div class="work-actions">
            <el-button size="small" @click="toggleWorkMode">
              <el-icon><component :is="workMode === 'grid' ? 'Grid' : 'List'" /></el-icon>
              {{ workMode === 'grid' ? '网格视图' : '列表视图' }}
            </el-button>
            <el-button size="small" @click="refreshWorkArea">
              <el-icon><Refresh /></el-icon>
              刷新
            </el-button>
          </div>
        </div>

        <!-- 工作区内容 -->
        <div class="work-content">
          <!-- 网格视图 -->
          <div v-if="workMode === 'grid'" class="grid-view">
            <div
              v-for="item in workItems"
              :key="item.id"
              class="work-item"
              @click="openWorkItem(item)"
            >
              <div class="item-icon">
                <el-icon><component :is="item.icon" /></el-icon>
              </div>
              <div class="item-content">
                <h4>{{ item.title }}</h4>
                <p>{{ item.description }}</p>
                <div class="item-meta">
                  <el-tag v-if="item.status" size="small" :type="item.statusType">
                    {{ item.status }}
                  </el-tag>
                  <span class="item-time">{{ item.updateTime }}</span>
                </div>
              </div>
              <div class="item-actions">
                <el-button size="small" text @click.stop="editItem(item)">
                  <el-icon><Edit /></el-icon>
                </el-button>
                <el-button size="small" text @click.stop="deleteItem(item)">
                  <el-icon><Delete /></el-icon>
                </el-button>
              </div>
            </div>
          </div>

          <!-- 列表视图 -->
          <div v-else class="list-view">
            <el-table :data="workItems" style="width: 100%">
              <el-table-column prop="title" label="标题" width="200">
                <template #default="{ row }">
                  <div class="table-title">
                    <el-icon><component :is="row.icon" /></el-icon>
                    <span>{{ row.title }}</span>
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="description" label="描述" />
              <el-table-column prop="status" label="状态" width="100">
                <template #default="{ row }">
                  <el-tag size="small" :type="row.statusType">{{ row.status }}</el-tag>
                </template>
              </el-table-column>
              <el-table-column prop="updateTime" label="更新时间" width="150" />
              <el-table-column label="操作" width="120">
                <template #default="{ row }">
                  <el-button size="small" text @click="editItem(row)">编辑</el-button>
                  <el-button size="small" text @click="deleteItem(row)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>

      <!-- 右侧信息面板 -->
      <div class="info-panel" :class="{ 'collapsed': isInfoPanelCollapsed }">
        <div class="panel-header">
          <h3>信息面板</h3>
          <el-button text @click="toggleInfoPanel">
            <el-icon><component :is="isInfoPanelCollapsed ? 'Expand' : 'Fold'" /></el-icon>
          </el-button>
        </div>

        <div class="panel-content">
          <!-- 统计信息 -->
          <div class="stats-section">
            <h4>统计信息</h4>
            <div class="stats-grid">
              <div class="stat-item">
                <div class="stat-value">{{ moduleStats.total }}</div>
                <div class="stat-label">总数</div>
              </div>
              <div class="stat-item">
                <div class="stat-value">{{ moduleStats.active }}</div>
                <div class="stat-label">活跃</div>
              </div>
              <div class="stat-item">
                <div class="stat-value">{{ moduleStats.pending }}</div>
                <div class="stat-label">待处理</div>
              </div>
            </div>
          </div>

          <!-- 快捷操作 -->
          <div class="quick-actions-section">
            <h4>快捷操作</h4>
            <div class="action-buttons">
              <el-button size="small" @click="createNew">
                <el-icon><Plus /></el-icon>
                新建
              </el-button>
              <el-button size="small" @click="importData">
                <el-icon><Upload /></el-icon>
                导入
              </el-button>
              <el-button size="small" @click="exportData">
                <el-icon><Download /></el-icon>
                导出
              </el-button>
            </div>
          </div>

          <!-- 最近活动 -->
          <div class="recent-activity-section">
            <h4>最近活动</h4>
            <div class="activity-list">
              <div
                v-for="activity in recentActivities"
                :key="activity.id"
                class="activity-item"
              >
                <div class="activity-icon">
                  <el-icon><component :is="activity.icon" /></el-icon>
                </div>
                <div class="activity-content">
                  <div class="activity-title">{{ activity.title }}</div>
                  <div class="activity-time">{{ activity.time }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 全局搜索面板 -->
    <transition name="search-slide">
      <div v-if="showGlobalSearch" class="global-search-panel">
        <div class="search-header">
          <el-input
            v-model="globalSearchQuery"
            placeholder="搜索功能、数据、操作..."
            size="large"
            @input="handleGlobalSearch"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
          <el-button @click="closeGlobalSearch">
            <el-icon><Close /></el-icon>
          </el-button>
        </div>
        <div class="search-results">
          <div class="search-tabs">
            <div
              v-for="tab in searchTabs"
              :key="tab.id"
              class="search-tab"
              :class="{ 'active': activeSearchTab === tab.id }"
              @click="selectSearchTab(tab.id)"
            >
              {{ tab.name }}
              <el-badge v-if="tab.count" :value="tab.count" class="tab-badge" />
            </div>
          </div>
          <div class="search-content">
            <div
              v-for="result in currentSearchResults"
              :key="result.id"
              class="search-result"
              @click="selectSearchResult(result)"
            >
              <el-icon><component :is="result.icon" /></el-icon>
              <div class="result-content">
                <div class="result-title">{{ result.title }}</div>
                <div class="result-desc">{{ result.description }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import {
  Grid, Search, Bell, User, Expand, Fold, ArrowDown, ArrowRight,
  Refresh, Edit, Delete, Plus, Upload, Download, ShoppingCart,
  ShoppingBag, Warehouse, Money, UserFilled, Setting, Document,
  List, TrendCharts, DataBoard
} from '@element-plus/icons-vue'

const router = useRouter()

// 响应式数据
const activeModule = ref('sales')
const isSidebarCollapsed = ref(false)
const isInfoPanelCollapsed = ref(false)
const showGlobalSearch = ref(false)
const globalSearchQuery = ref('')
const workMode = ref('grid')
const activeFunction = ref('')
const activeSearchTab = ref('all')

// 模块数据
const modules = ref([
  {
    id: 'sales',
    name: '销售管理',
    description: '销售订单、客户管理',
    icon: 'ShoppingCart',
    badge: 'HOT',
    badgeType: 'danger'
  },
  {
    id: 'purchase',
    name: '采购管理',
    description: '采购订单、供应商管理',
    icon: 'ShoppingBag',
    badge: 'NEW',
    badgeType: 'success'
  },
  {
    id: 'inventory',
    name: '库存管理',
    description: '库存查询、仓库管理',
    icon: 'Warehouse',
    badge: '',
    badgeType: ''
  },
  {
    id: 'finance',
    name: '财务管理',
    description: '财务报表、会计核算',
    icon: 'Money',
    badge: '',
    badgeType: ''
  },
  {
    id: 'hr',
    name: '人力资源',
    description: '员工管理、考勤管理',
    icon: 'UserFilled',
    badge: '',
    badgeType: ''
  },
  {
    id: 'system',
    name: '系统管理',
    description: '用户管理、系统设置',
    icon: 'Setting',
    badge: '',
    badgeType: ''
  }
])

// 功能分类数据
const functionCategories = ref([
  {
    id: 'orders',
    name: '订单管理',
    icon: 'Document',
    expanded: true,
    functions: [
      { id: 'order-list', name: '订单列表', icon: 'List', count: 15 },
      { id: 'order-create', name: '新建订单', icon: 'Plus', count: 0 },
      { id: 'order-approval', name: '订单审批', icon: 'Check', count: 3 }
    ]
  },
  {
    id: 'customers',
    name: '客户管理',
    icon: 'User',
    expanded: false,
    functions: [
      { id: 'customer-list', name: '客户列表', icon: 'List', count: 0 },
      { id: 'customer-analysis', name: '客户分析', icon: 'TrendCharts', count: 0 }
    ]
  },
  {
    id: 'reports',
    name: '报表分析',
    icon: 'DataBoard',
    expanded: false,
    functions: [
      { id: 'sales-report', name: '销售报表', icon: 'TrendCharts', count: 0 },
      { id: 'customer-report', name: '客户报表', icon: 'DataBoard', count: 0 }
    ]
  }
])

// 工作项数据
const workItems = ref([
  {
    id: 1,
    title: '销售订单 #SO-2024-001',
    description: '客户：张三，金额：¥12,500',
    icon: 'Document',
    status: '待审批',
    statusType: 'warning',
    updateTime: '2024-01-15 14:30'
  },
  {
    id: 2,
    title: '销售订单 #SO-2024-002',
    description: '客户：李四，金额：¥8,900',
    icon: 'Document',
    status: '已完成',
    statusType: 'success',
    updateTime: '2024-01-15 10:20'
  },
  {
    id: 3,
    title: '客户信息 - 王五',
    description: '新增客户信息',
    icon: 'User',
    status: '草稿',
    statusType: 'info',
    updateTime: '2024-01-15 09:15'
  }
])

// 统计信息
const moduleStats = ref({
  total: 156,
  active: 89,
  pending: 12
})

// 最近活动
const recentActivities = ref([
  {
    id: 1,
    title: '创建了销售订单 #SO-2024-003',
    icon: 'Document',
    time: '2分钟前'
  },
  {
    id: 2,
    title: '更新了客户信息',
    icon: 'User',
    time: '15分钟前'
  },
  {
    id: 3,
    title: '导出了销售报表',
    icon: 'Download',
    time: '1小时前'
  }
])

// 搜索相关
const searchTabs = ref([
  { id: 'all', name: '全部', count: 0 },
  { id: 'functions', name: '功能', count: 0 },
  { id: 'data', name: '数据', count: 0 },
  { id: 'operations', name: '操作', count: 0 }
])

const searchResults = ref({
  all: [],
  functions: [],
  data: [],
  operations: []
})

// 计算属性
const activeModuleName = computed(() => {
  const module = modules.value.find(m => m.id === activeModule.value)
  return module?.name || ''
})

const workBreadcrumbs = computed(() => {
  return [
    { name: '首页', path: '/', icon: 'HomeFilled' },
    { name: activeModuleName.value, path: `/${activeModule.value}`, icon: 'Grid' }
  ]
})

const currentSearchResults = computed(() => {
  return searchResults.value[activeSearchTab.value] || []
})

// 方法
const selectModule = (module) => {
  activeModule.value = module.id
  // 更新功能分类数据
  updateFunctionCategories(module.id)
}

const updateFunctionCategories = (moduleId) => {
  // 根据模块ID更新功能分类
  const moduleData = {
    sales: [
      {
        id: 'orders',
        name: '订单管理',
        icon: 'Document',
        expanded: true,
        functions: [
          { id: 'order-list', name: '订单列表', icon: 'List', count: 15 },
          { id: 'order-create', name: '新建订单', icon: 'Plus', count: 0 }
        ]
      }
    ],
    purchase: [
      {
        id: 'purchase-orders',
        name: '采购订单',
        icon: 'Document',
        expanded: true,
        functions: [
          { id: 'purchase-list', name: '采购列表', icon: 'List', count: 8 },
          { id: 'supplier-management', name: '供应商管理', icon: 'Shop', count: 0 }
        ]
      }
    ]
  }
  
  functionCategories.value = moduleData[moduleId] || []
}

const toggleCategory = (categoryId) => {
  const category = functionCategories.value.find(c => c.id === categoryId)
  if (category) {
    category.expanded = !category.expanded
  }
}

const selectFunction = (func) => {
  activeFunction.value = func.id
  console.log('选择功能:', func)
}

const toggleSidebar = () => {
  isSidebarCollapsed.value = !isSidebarCollapsed.value
}

const toggleInfoPanel = () => {
  isInfoPanelCollapsed.value = !isInfoPanelCollapsed.value
}

const toggleWorkMode = () => {
  workMode.value = workMode.value === 'grid' ? 'list' : 'grid'
}

const refreshWorkArea = () => {
  ElMessage.success('工作区已刷新')
}

const openWorkItem = (item) => {
  console.log('打开工作项:', item)
}

const editItem = (item) => {
  console.log('编辑项目:', item)
}

const deleteItem = (item) => {
  console.log('删除项目:', item)
}

const createNew = () => {
  ElMessage.info('新建功能')
}

const importData = () => {
  ElMessage.info('导入数据')
}

const exportData = () => {
  ElMessage.info('导出数据')
}

const toggleGlobalSearch = () => {
  showGlobalSearch.value = !showGlobalSearch.value
}

const closeGlobalSearch = () => {
  showGlobalSearch.value = false
  globalSearchQuery.value = ''
}

const handleGlobalSearch = () => {
  if (!globalSearchQuery.value.trim()) {
    Object.keys(searchResults.value).forEach(key => {
      searchResults.value[key] = []
    })
    return
  }
  
  // 模拟搜索
  searchResults.value.all = [
    { id: 'search-1', title: '销售订单管理', description: '处理销售订单的完整流程', icon: 'Document' },
    { id: 'search-2', title: '客户信息查询', description: '查询和管理客户信息', icon: 'User' }
  ]
  
  searchResults.value.functions = searchResults.value.all.filter(r => r.title.includes('管理'))
  searchResults.value.data = searchResults.value.all.filter(r => r.title.includes('信息'))
  searchResults.value.operations = searchResults.value.all.filter(r => r.title.includes('查询'))
}

const selectSearchTab = (tabId) => {
  activeSearchTab.value = tabId
}

const selectSearchResult = (result) => {
  console.log('选择搜索结果:', result)
  closeGlobalSearch()
}

// 生命周期
onMounted(() => {
  updateFunctionCategories(activeModule.value)
})
</script>

<style scoped>
.modular-nav-system {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f7fa;
}

/* 顶部模块导航 */
.module-nav-bar {
  height: 80px;
  background: white;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: #409eff;
}

.module-tabs {
  flex: 1;
  display: flex;
  gap: 12px;
  overflow-x: auto;
}

.module-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
  border: 2px solid transparent;
}

.module-tab:hover {
  background: #f5f7fa;
  border-color: #e4e7ed;
}

.module-tab.active {
  background: #409eff;
  color: white;
  border-color: #409eff;
}

.tab-icon {
  font-size: 20px;
}

.tab-content {
  flex: 1;
}

.tab-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.tab-desc {
  font-size: 12px;
  opacity: 0.8;
}

.tab-badge {
  margin-left: 8px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 左侧功能面板 */
.function-sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.function-sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #e4e7ed;
  background: #fafafa;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.function-category {
  margin-bottom: 16px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-weight: 600;
}

.category-header:hover {
  background: #f5f7fa;
}

.expand-icon {
  margin-left: auto;
  transition: transform 0.2s;
}

.category-functions {
  margin-top: 8px;
  margin-left: 20px;
}

.function-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.function-item:hover {
  background: #f5f7fa;
}

.function-item.active {
  background: #ecf5ff;
  color: #409eff;
}

.function-badge {
  margin-left: auto;
}

/* 中间工作区域 */
.work-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.work-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: white;
  border-bottom: 1px solid #e4e7ed;
}

.work-breadcrumb {
  display: flex;
  align-items: center;
}

.work-actions {
  display: flex;
  gap: 8px;
}

.work-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f5f7fa;
}

/* 网格视图 */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.work-item {
  background: white;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  position: relative;
}

.work-item:hover {
  border-color: #409eff;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.15);
}

.item-icon {
  font-size: 24px;
  color: #409eff;
  margin-bottom: 12px;
}

.item-content h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.item-content p {
  margin: 0 0 12px 0;
  color: #606266;
  line-height: 1.5;
}

.item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.item-time {
  font-size: 12px;
  color: #909399;
}

.item-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.work-item:hover .item-actions {
  opacity: 1;
}

/* 列表视图 */
.list-view {
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.table-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 右侧信息面板 */
.info-panel {
  width: 300px;
  background: white;
  border-left: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.info-panel.collapsed {
  width: 0;
  border-left: none;
}

.panel-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #e4e7ed;
  background: #fafafa;
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.stats-section,
.quick-actions-section,
.recent-activity-section {
  margin-bottom: 24px;
}

.stats-section h4,
.quick-actions-section h4,
.recent-activity-section h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #303133;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-item {
  text-align: center;
  padding: 12px;
  background: #f5f7fa;
  border-radius: 6px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: #409eff;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #909399;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.activity-item:hover {
  background: #f5f7fa;
}

.activity-icon {
  width: 32px;
  height: 32px;
  background: #ecf5ff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #409eff;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.activity-time {
  font-size: 11px;
  color: #909399;
}

/* 全局搜索面板 */
.global-search-panel {
  position: fixed;
  top: 80px;
  left: 0;
  right: 0;
  height: 500px;
  background: white;
  border-bottom: 1px solid #e4e7ed;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.search-header {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #e4e7ed;
  gap: 12px;
}

.search-results {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.search-tabs {
  display: flex;
  border-bottom: 1px solid #e4e7ed;
  background: #fafafa;
}

.search-tab {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  position: relative;
}

.search-tab:hover {
  background: #f5f7fa;
}

.search-tab.active {
  background: white;
  border-bottom-color: #409eff;
  color: #409eff;
}

.tab-badge {
  margin-left: 8px;
}

.search-content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  margin-bottom: 8px;
}

.search-result:hover {
  background: #f5f7fa;
}

.result-content {
  flex: 1;
}

.result-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.result-desc {
  font-size: 12px;
  color: #909399;
}

/* 动画 */
.category-slide-enter-active,
.category-slide-leave-active {
  transition: all 0.3s ease;
}

.category-slide-enter-from {
  opacity: 0;
  transform: translateY(-10px);
}

.category-slide-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}

.search-slide-enter-active,
.search-slide-leave-active {
  transition: all 0.3s ease;
}

.search-slide-enter-from {
  transform: translateY(-100%);
}

.search-slide-leave-to {
  transform: translateY(-100%);
}

/* 响应式 */
@media (max-width: 1200px) {
  .info-panel {
    width: 250px;
  }
  
  .function-sidebar {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .module-tabs {
    display: none;
  }
  
  .function-sidebar,
  .info-panel {
    position: fixed;
    top: 80px;
    height: calc(100vh - 80px);
    z-index: 999;
  }
  
  .function-sidebar {
    left: 0;
  }
  
  .info-panel {
    right: 0;
  }
}
</style>
